package com.sdruixinggroup.mondayb2b.ui.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sdruixinggroup.mondayb2b.R;
import com.sdruixinggroup.mondayb2b.models.OrderInfor;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.sdruixinggroup.mondayb2b.utils.DisplayUtil.double2String;

/**
 * Created by 00029935 on 2018/1/22.
 */

public class CheckPayNongziFragment extends BaseFragment {

    @BindView(R.id.ib_back)
    ImageView ibBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.title_view)
    RelativeLayout titleView;
    @BindView(R.id.tv_order)
    TextView tvOrder;
    @BindView(R.id.tv_people)
    TextView tvPeople;
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    private OrderInfor.OrderBean orderBean;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        orderBean = (OrderInfor.OrderBean) getActivity().getIntent().getSerializableExtra("object");
    }

    @Override
    protected int getInflateLayout() {
        return R.layout.check_pay_nongzi_fragment_layout;
    }

    @Override
    protected void setUpView(View view) {
        tvTitle.setText("农资贷审核");
        OrderInfor.OrderBean.LoanBeen loanBeen =  orderBean.loan;
        setTextViewColor(tvOrder,"订单号&emsp&emsp&emsp&emsp",loanBeen.getOrder().getOrder_sn());
        setTextViewColor(tvPeople,"赊帐人&emsp&emsp&emsp&emsp",loanBeen.getBorrower().getUsername());
        setTextViewColor(tvTime,"赊帐周期&emsp&emsp&emsp",loanBeen.getStart_date()+"至"+loanBeen.getEnd_date());
        setTextViewColorC(tvMoney,"赊账金额&emsp&emsp&emsp", "¥"+double2String(loanBeen.getAmount()));
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @OnClick(R.id.ib_back)
    public void onClick() {
        getActivity().finish();
    }

    private void setTextViewColor(TextView textView,String name ,String value){

        textView.setText(Html.fromHtml( "<font color= '#333333'>"+name + "</font> "   +"<font color= '#666666'>"+value + "</font> "));
    }

    private void setTextViewColorC(TextView textView,String name ,String value){

        textView.setText(Html.fromHtml( "<font color= '#333333'>"+name + "</font> "   +"<font color= '#E94C5F'>"+value + "</font> "));
    }

}
